import UIAbility from '@ohos.app.ability.UIAbility';
import hilog from '@ohos.hilog';
import window from '@ohos.window';
import data from '@ohos.telephony.data';
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
import promptAction from '@ohos.promptAction';

export default class EntryAbility extends UIAbility {

  onWindowStageCreate(windowStage: window.WindowStage) {
    windowStage.loadContent('pages/day50_Video/toutiao/MainPage')
  }


  /**
   * day49_file
   * @param want
   * @param launchParam
   */
  // onCreate(want, launchParam) {
  //   let manager = abilityAccessCtrl.createAtManager()
  //   let permissions: Permissions[] =
  //     [
  //       "ohos.permission.READ_MEDIA",
  //       "ohos.permission.WRITE_MEDIA"
  //     ]
  //   try {
  //     manager.requestPermissionsFromUser(this.context, permissions)
  //   } catch (err) {
  //     promptAction.showToast({message: '获取权限失败!'})
  //   }
  // }
  //
  // onWindowStageCreate(windowStage: window.WindowStage) {
  //   windowStage.loadContent('pages/day49_file/PhotoPickerExample')
  // }


  /**
   * 实现发送通知
   */
  // //实现发送通知
  // onWindowStageCreate(windowStage: window.WindowStage) {
  //   windowStage.loadContent('pages/day45_window/notification/DownloadNotification')
  // }

  /**
   * 实现用户登录及验证码登录
   */
  // //实现用户登录及验证码登录
  // onWindowStageCreate(windowStage: window.WindowStage) {
  //   //存储
  //   AppStorage.SetOrCreate('windowStage', windowStage)
  //   //设置主窗口的沉浸效果
  //   windowStage.getMainWindow((err, windowClass: window.Window) => {
  //     //设置全屏
  //     windowClass.setWindowLayoutFullScreen(true)
  //     //取消任务栏和状态栏
  //     windowClass.setWindowSystemBarEnable([])
  //   })
  //   windowStage.loadContent('pages/day45_window/login_window/LoginPage')
  // }


  /**
   * UIAbility实例创建
   */
  // //1.UIAbility实例创建，进行页面初始化、一些资源的加载
  // onCreate(want, launchParam) {
  //   hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
  // }
  //
  // //UIAbility实例销毁执行的
  // onDestroy() {
  //   hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
  // }
  //
  // onWindowStageCreate(windowStage: window.WindowStage) {
  //
  //   AppStorage.SetOrCreate('windowStage', windowStage)
  //   let windowClass: window.Window = null
  //   //1.获取应用主窗口
  //   windowStage.getMainWindow((err, data: window.Window) => {
  //     windowClass = data
  //     //2.设置应用主窗口
  //     //2.1取消状态栏和任务栏
  //     windowClass.setWindowSystemBarEnable([])
  //     //2.2设置全屏
  //     windowClass.setWindowLayoutFullScreen(true)
  //     //2.3设置是否可触摸
  //     windowClass.setWindowTouchable(true)
  //   })
  //
  //
  //   // Main window is created, set main page for this ability
  //   hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
  //   //3.加载页面
  //   windowStage.loadContent('pages/day45_window/WindowStagePage', (err, data) => {
  //     if (err.code) {
  //       hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
  //       return;
  //     }
  //     //4.页面加载成功
  //     hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
  //   });
  //
  //   //2.4设置窗口背景色
  //   windowStage.getMainWindow((err, data: window.Window) => {
  //     // data.setWindowBackgroundColor('#ff0000')
  //   })
  // }
  //
  // onWindowStageDestroy() {
  //   // Main window is destroyed, release UI related resources
  //   hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
  // }
  //
  // //3.UIAbility切换至前台
  // onForeground() {
  //   // Ability has brought to foreground
  //   hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
  // }
  //
  // //UIAbility切换至后台
  // onBackground() {
  //   // Ability has back to background
  //   hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
  // }
}
